Use case: COMP comparing by polling ¶
Description of usage ¶
|
Operation |
HAL1 |
HAL2 |
|---|---|---|
|
Start comparing |
Activate Comparator analog features using:
|
Activate Comparator analog features using
|
|
Retrieve comparing result |
Retrieve comparing results using:
|
Retrieve comparing results using:
|
|
Loop for multiple iterations |
Possible multiple iterations if the comparator output has changed since the last read. |
Possible multiple iterations if the comparator output has changed since the last read. |
|
Stop comparing |
Stop Comparator analog features using:
|
Stop Comparator analog features using
|
Sequence diagram ¶
Code snippet ¶
|
HAL1 / HAL2 |
|---|
uint32_t comp_output_register_state = HAL_COMP_OUTPUT_LEVEL_LOW;
/*initialize and configure your comparing input*/
/* Start the COMP */
HAL_COMP_Start(&comp1);
while(comp_output_register_state == HAL_COMP_OUTPUT_LEVEL_HIGH)
{
/* generate voltage on comparator inputs */
/* add a Wait time for voltage stabilization*/
/* Check comparator output: digital flag */
comp_output_register_state = HAL_COMP_GetOutputLevel(&comp1);
}
/* Stop the COMP */
HAL_COMP_Stop(&hcomp1);
|
Key changes ¶
No major changes between HAL1 and HAL2.
